﻿using System;
using System.Windows.Forms;
using DocumentManager.Abstractions.Interfaces.Helpers;
using DocumentManager.Common;

namespace DocumentManager.Forms
{
	public partial class frmInfoCompanySettings : Form
	{
		#region Variables

		private readonly IApplicationConfiguration _applicationConfiguration;

		#endregion

		#region Constructors

		public frmInfoCompanySettings(IApplicationConfiguration applicationConfiguration)
		{
			if (applicationConfiguration == null)
				throw new ArgumentNullException(string.Format("application Configuration"));
			_applicationConfiguration = applicationConfiguration;

			InitializeComponent();
			FillFormElements();
		}

		#endregion

		#region Form Actions

		private void btnSave_Click(object sender, EventArgs e)
		{
			this.Enabled = false;

			_applicationConfiguration.Director = txtDirector.Text;
			_applicationConfiguration.Performer = txtPerformer.Text;

			MessageBox.Show(Constants.SAVE_OPERATION_SUCCESFULL_COMPLETE);

			this.Enabled = true;
		}

		#endregion

		#region Internal Implementation

		private void FillFormElements()
		{
			txtDirector.Text = _applicationConfiguration.Director ?? string.Empty;
			txtPerformer.Text = _applicationConfiguration.Performer ?? string.Empty;
		}

		#endregion
	}
}
